package com.css.dzj.dzjportal.modules.promulgate.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.css.dzj.dzjportal.common.util.http.HttpClientUtil;
import com.css.dzj.dzjportal.modules.promulgate.entity.ProEntity;
import com.css.dzj.dzjportal.modules.promulgate.service.ProService;
import com.querydsl.core.QueryResults;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ProServiceImpl implements ProService {
    @Value("${AP_URL}")
    private String apUrl;
    @Value("${WGR_URL}")
    private String wgrUrl;
    @Value("${JCSS_URL}")
    private String jcssUrl;
    @Value("${XCJY_URL}")
    private String xcjyUrl;
    @Override
    public QueryResults<ProEntity> titleList(PageRequest pageRequest,String title, String publicType,Integer pageSize,Integer pageNo,String isPublic) {
        try {
            String msg = HttpClientUtil.doGet(apUrl + "/publick/titleList?title="+title+"&publicType="+publicType+"&isPublic="+isPublic);
            String wgrmsg = HttpClientUtil.doGet(wgrUrl + "/publicity/listPublicity?title="+title+"&publicType="+publicType+"&isPublic="+isPublic);
            String jcssmsg = HttpClientUtil.doGet(jcssUrl + "/publicity/termList?title="+title+"&publicType="+publicType+"&isPublic="+isPublic);
            String xcjymsg = HttpClientUtil.doGet(xcjyUrl + "/publicity/termList?title="+title+"&publicType="+publicType+"&isPublic="+isPublic);
            //转为JSON数组
            JSONArray jsonObject = null;
            JSONArray wgrjsonObject = null;
            JSONArray jcssjsonObject = null;
            JSONArray xcjyjsonObject = null;

            Object obj = JSON.parse(msg);
            Object wgr = JSON.parse(wgrmsg);
            Object jcss = JSON.parse(jcssmsg);
            Object xcjy = JSON.parse(xcjymsg);
            if(obj instanceof  JSONArray){
                jsonObject = JSON.parseArray(msg);
            }
            if(wgr instanceof  JSONArray){
                wgrjsonObject = JSON.parseArray(wgrmsg);
            }
            if(jcss instanceof  JSONArray){
                jcssjsonObject = JSON.parseArray(jcssmsg);
            }
            if(xcjy instanceof  JSONArray){
                xcjyjsonObject = JSON.parseArray(xcjymsg);
            }
            List<ProEntity> plist = new ArrayList<>();
            //获取安平系统的数据
            if(jsonObject!=null && !"".equals(jsonObject)) {
                for (int i = 0;i<jsonObject.size();i++){
                    Map<String, Object> eventMap = JSONObject.parseObject(jsonObject.get(i).toString());
                    ProEntity pe = new ProEntity();
                    pe.setId((String)eventMap.get("publicId"));
                    pe.setTitle((String)eventMap.get("title"));
                    pe.setCreateUser((String)eventMap.get("createUser"));
                    pe.setCreateUserUnit("无");
                    pe.setPublicityContent((String)eventMap.get("content"));
                    pe.setStatus((String)eventMap.get("publishType"));
                    pe.setCreateTime((String)eventMap.get("createTime"));
                    pe.setReleaseTime((String)eventMap.get("publishTime"));
                    //pe.setCommentCode();
                    pe.setCommAttachment((String)eventMap.get("enclosure"));
                    pe.setIsPublic((String)eventMap.get("isPublic"));
                    pe.setPublicityLevel("安平未等级");
                    pe.setPublicityDay("无");
                    pe.setUpdateTime("无");
                    pe.setUpdateUser("无");
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("0");
                    pe.setPublicType((String)eventMap.get("publicType"));
                    pe.setCondate((String)eventMap.get("publishTime"));
                    plist.add(pe);
                }
            }
            //获取外国人系统数据
            if(wgrjsonObject!=null && !"".equals(wgrjsonObject)) {
                for (int i = 0;i<wgrjsonObject.size();i++){
                    Map<String, Object> eventMap = JSONObject.parseObject(wgrjsonObject.get(i).toString());
                    ProEntity pe = new ProEntity();
                    System.out.println();
                    pe.setId((String)eventMap.get("id"));
                    pe.setTitle((String)eventMap.get("title"));
                    pe.setCreateUser((String)eventMap.get("createUser"));
                    pe.setCreateUserUnit("createUserUnit");
                    pe.setPublicityContent((String)eventMap.get("publicityContent"));
                    pe.setStatus((String)eventMap.get("status"));
                    pe.setCreateTime((String)eventMap.get("createTime"));
                    pe.setReleaseTime((String)eventMap.get("releaseTime"));
                    pe.setCommentCode((String)eventMap.get("commentCode"));
                    pe.setCommAttachment((String)eventMap.get("commAttachment"));
                    pe.setPublicityLevel((String)eventMap.get("publicityLevel"));
                    pe.setPublicityDay((String)eventMap.get("publicityDay"));
                    pe.setUpdateTime((String)eventMap.get("updateTime"));
                    pe.setUpdateUser((String)eventMap.get("updateUser"));
                    pe.setIsPublic((String)eventMap.get("isPublic"));
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("1");
                    pe.setPublicType((String)eventMap.get("publicType"));
                    pe.setCondate((String)eventMap.get("releaseTime"));
                    plist.add(pe);
                }
            }
            //获取监测设施系统数据
            if(jcssjsonObject!=null && !"".equals(jcssjsonObject)) {
                for (int i = 0;i<jcssjsonObject.size();i++){
                    Map<String, Object> eventMap = JSONObject.parseObject(jcssjsonObject.get(i).toString());
                    ProEntity pe = new ProEntity();
                    System.out.println();
                    pe.setId((String)eventMap.get("id"));
                    pe.setTitle((String)eventMap.get("title"));
                    pe.setCreateUser((String)eventMap.get("createUser"));
                    pe.setCreateUserUnit("createUserUnit");
                    pe.setPublicityContent((String)eventMap.get("publicityContent"));
                    pe.setStatus((String)eventMap.get("status"));
                    pe.setCreateTime((String)eventMap.get("createTime"));
                    pe.setReleaseTime((String)eventMap.get("releaseTime"));
                    pe.setCommentCode((String)eventMap.get("commentCode"));
                    pe.setCommAttachment((String)eventMap.get("commAttachment"));
                    pe.setPublicityLevel((String)eventMap.get("publicityLevel"));
                    pe.setPublicityDay((String)eventMap.get("publicityDay"));
                    pe.setUpdateTime((String)eventMap.get("updateTime"));
                    pe.setUpdateUser((String)eventMap.get("updateUser"));
                    pe.setIsPublic((String)eventMap.get("isPublic"));
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("2");
                    pe.setPublicType((String)eventMap.get("publicType"));
                    pe.setCondate((String)eventMap.get("releaseTime"));
                    plist.add(pe);
                }
            }
            //获取宣传教育系统数据
            if(xcjyjsonObject!=null && !"".equals(xcjyjsonObject)) {
                for (int i = 0;i<xcjyjsonObject.size();i++){
                    Map<String, Object> eventMap = JSONObject.parseObject(xcjyjsonObject.get(i).toString());
                    ProEntity pe = new ProEntity();
                    pe.setId((String)eventMap.get("id"));
                    pe.setTitle((String)eventMap.get("title"));
                    pe.setCreateUser((String)eventMap.get("createUser"));
                    pe.setCreateUserUnit("createUserUnit");
                    pe.setPublicityContent((String)eventMap.get("publicityContent"));
                    pe.setStatus((String)eventMap.get("status"));
                    pe.setCreateTime((String)eventMap.get("createTime"));
                    pe.setReleaseTime((String)eventMap.get("releaseTime"));
                    pe.setCommentCode((String)eventMap.get("commentCode"));
                    pe.setCommAttachment((String)eventMap.get("commAttachment"));
                    pe.setPublicityLevel((String)eventMap.get("publicityLevel"));
                    pe.setPublicityDay((String)eventMap.get("publicityDay"));
                    pe.setUpdateTime((String)eventMap.get("updateTime"));
                    pe.setUpdateUser((String)eventMap.get("updateUser"));
                    pe.setIsPublic((String)eventMap.get("isPublic"));
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施，3表示宣传教育
                    pe.setFrom("3");
                    pe.setPublicType((String)eventMap.get("publicType"));
                    pe.setCondate((String)eventMap.get("releaseTime"));
                    plist.add(pe);
                }
            }

            List<ProEntity> currentPageList = new ArrayList<>();
            //将数据按照发布时间降序排
            if(null != plist && plist.size()>0){
                List<ProEntity> proEntityList = new ArrayList<>();
                for(ProEntity cpList : plist ){
                    if (null!=cpList.getReleaseTime()){
                        proEntityList.add(cpList);
                    }
                }
                if(null != proEntityList && proEntityList.size()>0){
                    List<ProEntity> pEList = proEntityList.stream().sorted(Comparator.comparing(ProEntity::getReleaseTime).reversed()).collect(Collectors.toList());
                    int currIdx = (pageNo > 1 ? (pageNo - 1) * pageSize : 0);
                    for (int i = 0; i < pageSize && i < pEList.size() - currIdx; i++) {
                        ProEntity data = pEList.get(currIdx + i);
                        currentPageList.add(data);
                    }
                    QueryResults<ProEntity> rwsQueryResults = new QueryResults(currentPageList, (long)pageRequest.getPageSize(), pageRequest.getOffset(), pEList.size());
                    return rwsQueryResults;
                }
            }
            QueryResults<ProEntity> rwsQueryResults = new QueryResults(currentPageList, (long)pageRequest.getPageSize(), pageRequest.getOffset(), plist.size());
            return rwsQueryResults;
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }

    @Override
    @Transactional
    public QueryResults<ProEntity> allList(PageRequest pageRequest, String publicType,Integer pageSize,Integer pageNo,String isPublic) {
        try {
            String msg = HttpClientUtil.doGet(apUrl + "/publick/allList?publicType="+ publicType+"&isPublic="+isPublic);
            String wgrmsg = HttpClientUtil.doGet(wgrUrl + "/publicity/queryAllPublicity?publicType="+ publicType+"&isPublic="+isPublic);
            String jcssmsg = HttpClientUtil.doGet(jcssUrl + "/publicity/pageList?publicType="+ publicType+"&isPublic="+isPublic);
            String xcjymsg = HttpClientUtil.doGet(xcjyUrl + "/publicity/pageList?publicType="+publicType+"&isPublic="+isPublic);
            //转为JSON数组
            JSONArray jsonObject = null;
            JSONArray wgrjsonObject = null;
            JSONArray jcssjsonObject = null;
            JSONArray xcjyjsonObject = null;

            Object obj = JSON.parse(msg);
            Object wgr = JSON.parse(wgrmsg);
            Object jcss = JSON.parse(jcssmsg);
            Object xcjy = JSON.parse(xcjymsg);
            if(obj instanceof  JSONArray){
               jsonObject = JSON.parseArray(msg);
            }
            if(wgr instanceof  JSONArray){
                 wgrjsonObject = JSON.parseArray(wgrmsg);
            }
            if(jcss instanceof  JSONArray){
                jcssjsonObject = JSON.parseArray(jcssmsg);
            }
            if(xcjy instanceof  JSONArray){
                xcjyjsonObject = JSON.parseArray(xcjymsg);
            }

            List<ProEntity> plist = new ArrayList<>();
            //获取安平系统的数据
            if(jsonObject!=null && !"".equals(jsonObject)){
                for (int i = 0;i<jsonObject.size();i++){
                    Map<String, Object> eventMap = JSONObject.parseObject(jsonObject.get(i).toString());
                    System.out.println(eventMap.get("publicId"));
                    ProEntity pe = new ProEntity();
                    pe.setId((String)eventMap.get("publicId"));
                    pe.setTitle((String)eventMap.get("title"));
                    pe.setCreateUser((String)eventMap.get("createUser"));
                    pe.setCreateUserUnit("无");
                    pe.setPublicityContent((String)eventMap.get("content"));
                    pe.setStatus((String)eventMap.get("publishType"));
                    pe.setCreateTime((String)eventMap.get("createTime"));
                    pe.setReleaseTime((String)eventMap.get("publishTime"));
                    //pe.setCommentCode();
                    pe.setCommAttachment((String)eventMap.get("enclosure"));
                    pe.setIsPublic((String)eventMap.get("isPublic"));
                    pe.setPublicityLevel("安平未等级");
                    pe.setPublicityDay("无");
                    pe.setUpdateTime("无");
                    pe.setUpdateUser("无");
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("0");
                    pe.setPublicType((String)eventMap.get("publicType"));
                    pe.setCondate((String)eventMap.get("publishTime"));
                    plist.add(pe);
                }
            }
            //获取外国人系统数据
            if(wgrjsonObject!=null && !"".equals(wgrjsonObject)){
                for (int i = 0;i<wgrjsonObject.size();i++){
                    Map<String, Object> eventMap = JSONObject.parseObject(wgrjsonObject.get(i).toString());
                    ProEntity pe = new ProEntity();
                    pe.setId((String)eventMap.get("id"));
                    pe.setTitle((String)eventMap.get("title"));
                    pe.setCreateUser((String)eventMap.get("createUser"));
                    pe.setCreateUserUnit("createUserUnit");
                    pe.setPublicityContent((String)eventMap.get("publicityContent"));
                    pe.setStatus((String)eventMap.get("status"));
                    pe.setCreateTime((String)eventMap.get("createTime"));
                    pe.setReleaseTime((String)eventMap.get("releaseTime"));
                    pe.setCommentCode((String)eventMap.get("commentCode"));
                    pe.setCommAttachment((String)eventMap.get("commAttachment"));
                    pe.setPublicityLevel((String)eventMap.get("publicityLevel"));
                    pe.setPublicityDay((String)eventMap.get("publicityDay"));
                    pe.setUpdateTime((String)eventMap.get("updateTime"));
                    pe.setUpdateUser((String)eventMap.get("updateUser"));
                    pe.setIsPublic((String)eventMap.get("isPublic"));
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("1");
                    pe.setPublicType((String)eventMap.get("publicType"));
                    pe.setCondate((String)eventMap.get("releaseTime"));
                    plist.add(pe);
                }
            }
            //获取监测设施系统数据
            if(jcssjsonObject!=null && !"".equals(jcssjsonObject)){
                for (int i = 0;i<jcssjsonObject.size();i++){
                    System.out.println();
                    Map<String, Object> eventMap = JSONObject.parseObject(jcssjsonObject.get(i).toString());
                    ProEntity pe = new ProEntity();
                    pe.setId((String)eventMap.get("id"));
                    pe.setTitle((String)eventMap.get("title"));
                    pe.setCreateUser((String)eventMap.get("createUser"));
                    pe.setCreateUserUnit("createUserUnit");
                    pe.setPublicityContent((String)eventMap.get("publicityContent"));
                    pe.setStatus((String)eventMap.get("status"));
                    pe.setCreateTime((String)eventMap.get("createTime"));
                    pe.setReleaseTime((String)eventMap.get("releaseTime"));
                    pe.setCommentCode((String)eventMap.get("commentCode"));
                    pe.setCommAttachment((String)eventMap.get("commAttachment"));
                    pe.setPublicityLevel((String)eventMap.get("publicityLevel"));
                    pe.setPublicityDay((String)eventMap.get("publicityDay"));
                    pe.setUpdateTime((String)eventMap.get("updateTime"));
                    pe.setUpdateUser((String)eventMap.get("updateUser"));
                    pe.setIsPublic((String)eventMap.get("isPublic"));
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("2");
                    pe.setPublicType((String)eventMap.get("publicType"));
                    pe.setCondate((String)eventMap.get("releaseTime"));
                    plist.add(pe);
                }
            }
            //获取宣传教育系统数据
            if(xcjyjsonObject!=null && !"".equals(xcjyjsonObject)){
                for (int i = 0;i<xcjyjsonObject.size();i++){
                    Map<String, Object> eventMap = JSONObject.parseObject(xcjyjsonObject.get(i).toString());
                    System.out.println();
                    ProEntity pe = new ProEntity();
                    pe.setId((String)eventMap.get("id"));
                    pe.setTitle((String)eventMap.get("title"));
                    pe.setCreateUser((String)eventMap.get("createUser"));
                    pe.setCreateUserUnit("createUserUnit");
                    pe.setPublicityContent((String)eventMap.get("publicityContent"));
                    pe.setStatus((String)eventMap.get("status"));
                    pe.setCreateTime((String)eventMap.get("createTime"));
                    pe.setReleaseTime((String)eventMap.get("releaseTime"));
                    pe.setCommentCode((String)eventMap.get("commentCode"));
                    pe.setCommAttachment((String)eventMap.get("commAttachment"));
                    pe.setPublicityLevel((String)eventMap.get("publicityLevel"));
                    pe.setPublicityDay((String)eventMap.get("publicityDay"));
                    pe.setUpdateTime((String)eventMap.get("updateTime"));
                    pe.setUpdateUser((String)eventMap.get("updateUser"));
                    pe.setIsPublic((String)eventMap.get("isPublic"));
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施, 3表示宣传教育
                    pe.setFrom("3");
                    pe.setPublicType((String)eventMap.get("publicType"));
                    pe.setCondate((String)eventMap.get("releaseTime"));
                    plist.add(pe);
                }
            }
            List<ProEntity> currentPageList = new ArrayList<>();
            //将数据按照发布时间降序排
            if(null != plist && plist.size()>0){
                List<ProEntity> proEntityList = new ArrayList<>();
                for(ProEntity cpList : plist ){
                    if (null!=cpList.getReleaseTime()){
                        proEntityList.add(cpList);
                    }
                }
                if(null != proEntityList && proEntityList.size()>0){
                    List<ProEntity> pEList = proEntityList.stream().sorted(Comparator.comparing(ProEntity::getReleaseTime).reversed()).collect(Collectors.toList());
                    int currIdx = (pageNo > 1 ? (pageNo - 1) * pageSize : 0);
                    for (int i = 0; i < pageSize && i < pEList.size() - currIdx; i++) {
                        ProEntity data = pEList.get(currIdx + i);
                        currentPageList.add(data);
                    }
                    QueryResults<ProEntity> rwsQueryResults = new QueryResults(currentPageList, (long)pageRequest.getPageSize(), pageRequest.getOffset(), pEList.size());
                    return rwsQueryResults;
                }
            }
            QueryResults<ProEntity> rwsQueryResults = new QueryResults(currentPageList, (long)pageRequest.getPageSize(), pageRequest.getOffset(), plist.size());
            return rwsQueryResults;
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }

    @Override
    public ProEntity selectOne(String id, String from) {
        ProEntity pe = new ProEntity();
        try {
            if(StringUtils.isEmpty(id)||StringUtils.isEmpty(from)){
                throw new RuntimeException("id和来自哪个系统不能为空");
            }else{
                if (from.equals("0")){
                    String msg = HttpClientUtil.doGet(apUrl + "/publick/publicEntity?id="+id);
                    Object JSONObject = JSON.parseObject(msg);
                    pe.setId((String) ((JSONObject) JSONObject).get("publicId"));
                    pe.setTitle((String) ((JSONObject) JSONObject).get("title"));
                    pe.setCreateUser((String) ((JSONObject) JSONObject).get("createUser"));
                    pe.setCreateUserUnit("无");
                    pe.setPublicityContent((String)((JSONObject) JSONObject).get("attachContent"));
                    pe.setStatus((String)((JSONObject) JSONObject).get("publishType"));
                    pe.setCreateTime((String)((JSONObject) JSONObject).get("createTime"));
                    pe.setReleaseTime((String)((JSONObject) JSONObject).get("publishTime"));
                    pe.setIsPublic((String)((JSONObject) JSONObject).get("isPublic"));
                    //pe.setCommentCode();
                    pe.setCommAttachment((String)((JSONObject) JSONObject).get("enclosure"));
                    pe.setPublicityLevel("安平未等级");
                    pe.setPublicityDay("无");
                    pe.setUpdateTime("无");
                    pe.setUpdateUser("无");
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("0");
                    pe.setPublicType((String)((JSONObject) JSONObject).get("publicType"));
                    return pe;
                }else if(from.equals("1")){
                    String msg = HttpClientUtil.doGet(wgrUrl + "/publicity/interfaceinfo?id="+id);
                    Object JSONObject = JSON.parseObject(msg);
                    pe.setId((String)((JSONObject) JSONObject).get("id"));
                    pe.setTitle((String)((JSONObject) JSONObject).get("title"));
                    pe.setCreateUser((String)((JSONObject) JSONObject).get("createUser"));
                    pe.setCreateUserUnit("createUserUnit");
                    pe.setPublicityContent((String)((JSONObject) JSONObject).get("publicityContent"));
                    pe.setStatus((String)((JSONObject) JSONObject).get("status"));
                    pe.setCreateTime((String)((JSONObject) JSONObject).get("createTime"));
                    pe.setReleaseTime((String)((JSONObject) JSONObject).get("releaseTime"));
                    pe.setCommentCode((String)((JSONObject) JSONObject).get("commentCode"));
                    pe.setCommAttachment((String)((JSONObject) JSONObject).get("commAttachment"));
                    pe.setPublicityLevel((String)((JSONObject) JSONObject).get("publicityLevel"));
                    pe.setPublicityDay((String)((JSONObject) JSONObject).get("publicityDay"));
                    pe.setUpdateTime((String)((JSONObject) JSONObject).get("updateTime"));
                    pe.setUpdateUser((String)((JSONObject) JSONObject).get("updateUser"));
                    pe.setIsPublic((String)((JSONObject) JSONObject).get("isPublic"));
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("1");
                    pe.setPublicType((String)((JSONObject) JSONObject).get("publicType"));
                    return pe;
                }else if (from.equals("2")){
                    String msg = HttpClientUtil.doGet(jcssUrl + "/publicity/infoPublic?id="+id);
                    System.out.println();
                    Object JSONObject = JSON.parseObject(msg);
                    pe.setId((String)((JSONObject) JSONObject).get("id"));
                    pe.setTitle((String)((JSONObject) JSONObject).get("title"));
                    pe.setCreateUser((String)((JSONObject) JSONObject).get("createUser"));
                    pe.setCreateUserUnit("createUserUnit");
                    pe.setPublicityContent((String)((JSONObject) JSONObject).get("publicityContent"));
                    pe.setStatus((String)((JSONObject) JSONObject).get("status"));
                    pe.setCreateTime((String)((JSONObject) JSONObject).get("createTime"));
                    pe.setReleaseTime((String)((JSONObject) JSONObject).get("releaseTime"));
                    pe.setCommentCode((String)((JSONObject) JSONObject).get("commentCode"));
                    pe.setCommAttachment((String)((JSONObject) JSONObject).get("commAttachment"));
                    pe.setPublicityLevel((String)((JSONObject) JSONObject).get("publicityLevel"));
                    pe.setPublicityDay((String)((JSONObject) JSONObject).get("publicityDay"));
                    pe.setUpdateTime((String)((JSONObject) JSONObject).get("updateTime"));
                    pe.setUpdateUser((String)((JSONObject) JSONObject).get("updateUser"));
                    pe.setIsPublic((String)((JSONObject) JSONObject).get("isPublic"));
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("2");
                    pe.setPublicType((String)((JSONObject) JSONObject).get("publicType"));
                    return pe;
                }else if(from.equals("3")){
                    String msg = HttpClientUtil.doGet(xcjyUrl + "/publicity/infoPublic?id="+id);
                    System.out.println();
                    Object JSONObject = JSON.parseObject(msg);
                    pe.setId((String)((JSONObject) JSONObject).get("id"));
                    pe.setTitle((String)((JSONObject) JSONObject).get("title"));
                    pe.setCreateUser((String)((JSONObject) JSONObject).get("createUser"));
                    pe.setCreateUserUnit("createUserUnit");
                    pe.setPublicityContent((String)((JSONObject) JSONObject).get("publicityContent"));
                    pe.setStatus((String)((JSONObject) JSONObject).get("status"));
                    pe.setCreateTime((String)((JSONObject) JSONObject).get("createTime"));
                    pe.setReleaseTime((String)((JSONObject) JSONObject).get("releaseTime"));
                    pe.setCommentCode((String)((JSONObject) JSONObject).get("commentCode"));
                    pe.setCommAttachment((String)((JSONObject) JSONObject).get("commAttachment"));
                    pe.setPublicityLevel((String)((JSONObject) JSONObject).get("publicityLevel"));
                    pe.setPublicityDay((String)((JSONObject) JSONObject).get("publicityDay"));
                    pe.setUpdateTime((String)((JSONObject) JSONObject).get("updateTime"));
                    pe.setUpdateUser((String)((JSONObject) JSONObject).get("updateUser"));
                    pe.setIsPublic((String)((JSONObject) JSONObject).get("isPublic"));
                    //0表示来自安平，1表示来自外国人，2表示来自监测设施
                    pe.setFrom("3");
                    pe.setPublicType((String)((JSONObject) JSONObject).get("publicType"));
                    return pe;
                }
            }
            return pe;
        } catch(Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }
}
